#ifndef THREAD_POOL_H
#define THREAD_POOL_H

#include "gx_lsq.h"
#include <pthread.h>

typedef struct th_pool
{
	pthread_t *thread;
	QUEUE *queue;
	int nthreads;
	pthread_cond_t cond;
	pthread_mutex_t mutex;
	int keepworking;
}THREAD_POOL;


typedef struct queue_node
{
	void* (*function)(void *arg);
	void* arg;
}TASK;


THREAD_POOL* threadpool_init(int nthreads);
void threadpool_add(THREAD_POOL *thpool,void*(*function)(void *arg),void *arg);
void threadpool_destroy(THREAD_POOL *thpool);
#endif
